<?php

namespace JsonLowCode\UI;

use Closure;
use JsonLowCode\Schema;
use JsonLowCode\UI\Traits\HasModel;

/**
 * Input组件
 * @method static ImageVerify make() ImageVerify组件
 */
class ImageVerify extends Schema
{

    use HasModel;

    public function __construct()
    {
        parent::__construct();
        $this->componentName("ImageVerify");
    }


    /**
     * 设置图片验证码
     * 设置组件 v-model:modelValue
     * @param string $bindValue
     * @param Closure|null $closure
     * @return $this
     */
    public function modelValue(string $bindValue,  Closure $closure = null): static
    {
        return $this->bindModel("code", $bindValue, $closure);
    }


    /**
     * 设置图片验证码
     * @param string $code
     * @return $this
     */
    public function code(string $code): static
    {
        return $this->prop("code", $code);
    }


    /**
     * 设置图片验证码宽
     * @param string|int $width
     * @return $this
     */
    public function width(string|int $width= 152): static
    {
        return $this->prop("width",$width);
    }

    /**
     * 设置图片验证码高
     * @param string|int $height
     * @return $this
     */
    public function height(string|int $height = 40): static
    {
        return $this->prop("height",$height);
    }


    /**
     * 设置图片验证码宽高
     * @param string|int $width
     * @param string|int $height
     * @return $this
     */
    public function verify(string|int $width = 152, string|int $height = 40): static
    {
        $this->width($width);
        $this->height($height);
        return $this;
    }
}
